const read = name => {
  const obj = require(`../asset/${name}`)
  const newObj = {}

  if (typeof obj === 'object') {
    for (const key in obj) {
      if (Object.hasOwnProperty.call(obj, key)) {
        const item = obj[key]
        if (typeof item === 'string') {
          newObj.default ? (newObj.default[key] = item) : (newObj.default = { [key]: item })
        } else if (typeof item === 'object') {
          newObj[key] = item
        } else {
          newObj.default = {}
        }
      }
    }
    return newObj
  } else {
    console.error('-------', 'error: file module is not object')
    return {
      default: {},
    }
  }
}

module.exports = read
